package de.jmda.core.util;

import java.lang.annotation.Annotation;
import java.util.HashSet;
import java.util.Set;

public abstract class TypeUtil
{
	@SafeVarargs
  public static Set<Class<? extends Annotation>> createAnnotationsSet(
			Class<? extends Annotation> ... annotationTypes)
	{
		Set<Class<? extends Annotation>> result = new HashSet<>();
		
		for (Class<? extends Annotation> annotationType : annotationTypes)
		{
			result.add(annotationType);
		}
		
		return result;
	}

  public static String getPackageNameFromQualifiedTypeName(String qualifiedTypeName)
  {
  	int lastIndexOfPackageName = qualifiedTypeName.lastIndexOf(".");
  	
  	if (lastIndexOfPackageName < 0)
  	{
  		return "";
  	}
  	
  	return qualifiedTypeName.substring(0, qualifiedTypeName.lastIndexOf("."));
  }

	public static String getSimpleNameFromQualifiedTypeName(String qualifiedTypeName)
  {
  	return qualifiedTypeName.substring(qualifiedTypeName.lastIndexOf(".") + 1);
  }
}